<%--
  Created by IntelliJ IDEA.
  User: 62585
  Date: 2021/4/6
  Time: 22:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>发送Json</title>
    <script type="text/javascript" src="script/jquery-1.7.2.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#send").click(function () {
                var employee = {id: 0, name: "john", gender: "male"};
                var empStr = JSON.stringify(employee);
                $.ajax({
                    url: "${pageContext.request.contextPath}/requestBodyTest",
                    type: "POST",
                    data: empStr,
                    contentType : "application/json",
                    success : function (data) {
                        alert(data)
                    }
                });
                return false;
            });
        })
    </script>
</head>
<body>
<button id="send" name="send">发送</button>
</body>
</html>
